package com.supermap.application.dao;

import com.supermap.application.entity.TIndexSysType;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 目标体系指标类型dao
 */

@Repository
public interface TargetManageIndexSysTypeDao extends JpaRepository<TIndexSysType,String> {

    //查询目标体系指标类型
    @Query("select t from TIndexSysType t where t.index_sys_code = :sys_code")
    List<TIndexSysType> findAllBySysCode(@Param("sys_code") String sys_code);

    //根据指标类型名称查询
    @Query("select t from TIndexSysType t where t.name = :name")
    TIndexSysType findByName(@Param("name") String name);

    //根据主键查找
    @Query("select t from TIndexSysType t where t.id = :id")
    TIndexSysType findById(@Param("id") String id);

    //根据指标分类名称和目标体系类型查询指标分类是否存在
    @Query("select t from TIndexSysType t where t.name = :name and t.index_sys_code = :sys_code")
    TIndexSysType findByNameAndIndex_sys_code(@Param("name") String name, @Param("sys_code") String sys_code);
}
